<%--
    Document   : order
    Created on : Mar 16, 2013, 1:46:39 PM
    Author     : duonghung1369
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib tagdir="/WEB-INF/tags/common_admin/" prefix="common" %>
<%@taglib uri="/struts-tags" prefix="s" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Administrator Page</title>
        <link rel="stylesheet" type="text/css" href="../resource/css/popup.css">
        <link rel="stylesheet" type="text/css" href="../resource/css/admin_style.css">
        <script type="text/javascript" src="../resource/js/adminfunctions.js"></script>
        <script type="text/javascript" src="../resource/js/ajaxfunctions.js"></script>
    </head>
    <body>
        <div class="admin-container">
            <common:header />
            <div class="leftColumn">
                <h2>Menu</h2>
                <div class="box sidemenu" style="height: 982px;">
                    <common:navigation />
                </div>
            </div>
            <div class="rightColumn">
                <div class="boxa round first grid">
                    <h2>Order Management</h2>
                    <div class="search" id="Search" style="width: 100%">
                        <label style="float: left">Search</label>
                        <input type="text" id="txtSearchConfirmation" placeholder="Confirmation number..." onkeypress="searchConfirmation(event);" style="float: left"/>

                        <label>From</label>
                        <input type="date" name="fromDate" value="" id="input-search-order-from" />
                        <label>To</label>
                        <input type="date" name="toDate" value="" id="input-search-order-to" />
                        <label>Status</label>
                        <s:if test="orderStatusList != null">
                            <select id="search-order-form-status-listbox" name="orderStatusId">
                                <option value="-1"></option>
                                <s:iterator value="orderStatusList" id="orderStatus">
                                    <option value="<s:property value="#orderStatus.id" />"><s:property value="#orderStatus.description" /></option>
                                </s:iterator>
                            </select>
                        </s:if>
                        <input type="button" onclick="searchOrderCriteria()" value="Search" class="custom-button" />
                    </div>
                    <table class="data display datatable" id="order-table">
                        <thead>
                            <tr>
                                <td class="sorting_disable" >Id</td>
                                <td class="sorting_disable" >Confirmation Number</td>
                                <td class="sorting_disable" >Customer</td>
                                <td class="sorting_disable" >Placed Date</td>
                                <td class="sorting_disable" >Delivery Date</td>
                                <td class="sorting_disable" >Order Amount</td>
                                <td class="sorting_disable" >Status</td>
                                <td class="sorting_disable" ></td>
                            </tr>
                        </thead>
                        <tbody>
                            <s:iterator value="orders" status="orderStatus" id="order">
                                <tr class="odd" onclick="displayUpdateOrderForm(this);" >
                                    <td id="row-order-id<s:property value="id"/>"><s:property value="id" /></td>
                                    <td id="row-order-confirmationString"><s:property value="confirmationString"/></td>
                                    <td id="row-order-username"><s:property value="user.username"/></td>
                                    <td><fmt:formatDate pattern="MM-dd-yyyy" value="${placedDatetime}"/></td>
                                    <td id="row-order-deliveredDatetime<s:property value="id"/>"><fmt:formatDate pattern="MM-dd-yyyy" value="${deliveredDatetime}"/></td>
                                    <td><s:property value="subAmount" /></td>
                                    <td id="row-orderstatus-description<s:property value="id"/>"><s:property value="orderStatus.description" /></td>
                                    <td><a href="../admin/orderDetail.html?orderId=<s:property value="id" />" class="custom-button" onclick="event.stopPropagation();">Detail</a> </td>
                                </tr>                            
                            </s:iterator>
                        </tbody>
                    </table>

                    <a href="#update-order-form" style="display: none;" class="custom-button" id="update-order-anchor">Update Category</a>
                    <div style="margin-top: 50px;">
                        <form name="updateOrderForm" method="POST" onsubmit="return false;">

                            <a href="#x" class="overlay" id="update-order-form"></a>
                            <div class="popup">
                                <h2 style="color: blue">Update order</h2>
                                <table border="0" cellspacing="20">
                                    <tbody>
                                        <tr>
                                            <td>ID</td>
                                            <td id="update-order-form-id"></td>
                                        </tr>
                                        <tr>
                                            <td>Delivered date</td>
                                            <td id="update-order-form-delivereddate"><input type="date" name="delivereddate" value=""/></td>
                                        </tr>
                                        <tr>
                                            <td>Status</td>
                                            <td id="update-order-form-status">
                                                <s:if test="orderStatusList != null">
                                                    <select id="update-order-form-status-listbox" name="orderStatusId">
                                                        <s:iterator value="orderStatusList" id="orderStatus">
                                                            <option value="<s:property value="#orderStatus.id" />"><s:property value="#orderStatus.description" /></option>
                                                        </s:iterator>
                                                    </select>
                                                </s:if>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td></td>
                                            <td>
                                                <input type="button" value="Update" class="custom-button" onclick="updateOrderAjax();" />
                                                <input type="reset" value="Reset" class="custom-button" />
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                                <a class="close" href="#close" id="update-order-form-close"></a>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div class="clear">
        </div>
        <!--    <div class="footer">Copyright <a href="#">ThinhNP</a>. All rights Reserved.</div>-->
        <common:footer />
    </body>
</html>
